package org.example.leetCode;

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author Administrator
 */
public class CQueue {
    Deque<Integer> into = new LinkedList<>();
    Deque<Integer> outo = new LinkedList<>();

    public CQueue() {
    }

    public void appendTail(int value) {
        into.offer(value);
    }

    public int deleteHead() {
        if (outo.isEmpty() && into.isEmpty()) {
            return -1;
        }
        if (outo.isEmpty()) {
            while (!into.isEmpty()) {
                outo.offer(into.poll());
            }
        }
        return outo.poll();
    }
}
